# 元素等待：
# 1、强制等待：sleep(3)
# 2、显式等待：driver.implicitly_wait(2) 几乎不用
# 3、隐式等待：WebDriverWait

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium import webdriver

driver = webdriver.Chrome()
driver.get('http://192.168.20.244/ecshop/admin/privilege.php?act=login')
driver.maximize_window()

driver.find_element(By.NAME,'username').send_keys('caichang')
driver.find_element(By.NAME,'password').send_keys('caichang1')
driver.find_element(By.CLASS_NAME,'btn-a').click()


driver.switch_to.frame('menu-frame')
WebDriverWait(driver,15).until(expected_conditions.visibility_of_element_located((By.LINK_TEXT,'商品列表')),'对不起，找不到元素！！')
driver.find_element(By.LINK_TEXT,'商品列表').click()



